extends "../cTDA/cTDA.gd"
func _info():
	pass

func _connect():
	._connect()

func _extInit():
	._extInit()
	chaName = "刺客"
	lv = 2
	attCoe.atk = 25 / 8.5 * 2 / 2
	attCoe.maxHp = 640 / 112.5 / 2

	addSkillTxt("刺客之道：攻击额外造成敌人生命上限2%伤害（不超过10倍攻击力）\n\t每2秒清除敌方对自身全体仇恨，并跳到敌方[生命比最低/生命值最低/物防最低]附近并对其附加1层<眩晕>")
var pw2 = 0.02
var sk2t = 0
var sk2flag = 0
func _onBattleStart():
	._onBattleStart()
	sk2t = 0
	sk2flag = 0

func _onAtkChara(atkinfo):
	if atkinfo.atkType != Chara.AtkType.EFF && sk2flag && self.id.find("cTDA_2_") != -1:
		atkinfo.hurtVal *= 2
		sk2flag = 0
		atkinfo.hitCha.addBuff(b_liuXue.new(2))
	if atkinfo.hitCha != self && atkinfo.atkType != Chara.AtkType.EFF && !atkinfo.isMiss:
		var dmg = atkinfo.hitCha.att.maxHp * pw2
		if dmg > att.atk * 10:dmg = att.atk * 10
		hurtChara(atkinfo.hitCha,dmg,Chara.HurtType.PHY,Chara.AtkType.EFF)
	._onAtkChara(atkinfo)

func _upS():
	._upS()
	sk2t += 1
	if sk2t == 2:
		sk2t = 0
		ckzd()

func ckzd():
	var chas = getAllChas(1)
	chas.sort_custom(self,"sort" + str(sys.rndRan(1,3)))
	for i in chas:
		if i.aiCha == self:
			i.aiCha = null
	jump(chas[0],self)
	self.aiCha = chas[0]
	chas[0].addBuff(ctrl.b_xuanyun.new(1))
	sk2flag = 1

func sort1(a,b):
	return (a.att.hp / a.att.maxHp) < (b.att.hp / b.att.maxHp)

func sort2(a,b):
	return a.att.hp < b.att.hp

func sort3(a,b):
	return a.att.def < b.att.def